import Vue from 'vue'
// base library
import {
    //菜单
    Dropdown, DropdownMenu, DropdownItem, Menu, Submenu, MenuItem, MenuItemGroup, Breadcrumb, BreadcrumbItem,

    //布局
    Row, Col, Tabs, TabPane, Main, Header, Footer, Container, PageHeader, Card, Scrollbar,

    //表单
    Form, FormItem, Autocomplete, Input, InputNumber, Radio, RadioGroup, RadioButton,
    Checkbox, CheckboxButton, CheckboxGroup, Switch, Select, Option, OptionGroup, Button, ButtonGroup,
    ColorPicker, DatePicker, Slider, Upload, Rate, Cascader,

    //提示
    Alert, Progress, Dialog, Tooltip, Message, Notification, MessageBox, Loading, Popconfirm,

    //表格
    Table, TableColumn, Pagination,

    //其他
    Tag, Tree, Timeline, TimelineItem, Carousel, CarouselItem, Divider,

} from 'element-ui'

// ext library
import SvgIcon from '@/components/Icons/SvgIcon'
import ElemePagination from '@/components/Pagination'


//global variable 
import apis from '@/apis'
import config from "@/config";

const components = [
    Dropdown, DropdownMenu, DropdownItem, Menu, Submenu, MenuItem, MenuItemGroup, Breadcrumb, BreadcrumbItem,

    Row, Col, Tabs, TabPane, Main, Header, Footer, Container, PageHeader, Card, Scrollbar,

    Form, FormItem, Autocomplete, Input, InputNumber, Radio, RadioGroup, RadioButton,
    Checkbox, CheckboxButton, CheckboxGroup, Switch, Select, Option, OptionGroup, Button, ButtonGroup,
    ColorPicker, DatePicker, Slider, Upload, Rate, Cascader,

    Alert, Progress, Dialog, Tooltip, Popconfirm,

    Table, TableColumn, Pagination,

    Tag, Tree, Timeline, TimelineItem, Carousel, CarouselItem, Divider,

];


//设置组件默认属性
Table.props.border = { type: Boolean, default: true }
Table.props.highlightCurrentRow = { type: Boolean, default: true }
Table.props.rowKey = { type: String, default: 'id' }
Dialog.props.destroyOnClose = { type: Boolean, default: true }
Cascader.props.clearable = { type: Boolean, default: true }
Select.props.clearable = { type: Boolean, default: true }
Input.props.clearable.default = true





//注册 Loading 指令
Vue.use(Loading.directive);
//注册组件
Vue.component('svg-icon', SvgIcon)
Vue.component('Pagination', ElemePagination)
components.map(component => {
    Vue.use(component)
});

// 引入所有的 svg
const req = require.context('@/assets/svg', false, /\.svg$/)
const requireAll = context => context.keys().map(context)
requireAll(req);

Vue.prototype.$apis = apis
Vue.prototype.$Conf = config
Vue.prototype.$message = Message
Vue.prototype.$notify = Notification
Vue.prototype.$confirm = MessageBox.confirm
Vue.prototype.$ELEMENT = { size: 'medium' };